using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using cframework;
using System.ComponentModel;
using Newtonsoft.Json;
using UnityEditorInternal;
using HybridCLR.Editor.Commands;
using HybridCLR.Editor;

namespace cframework
{
    [CreateAssetMenu(menuName = "cframework/HybridclrAssemblySetting")]
    public class HybridclrAssemblySetting : ScriptableObject
    {
        //[Title("HybridclrAssemblySetting")]
        public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions;
        public string[] hotUpdateAssemblies;
        public string[] patchAOTAssemblies;

        [ContextMenu("Enable")]
        public void Enable()
        {
            Set(true);
        }

        public void Set(bool enable)
        {
            if (enable)
            {
                SettingsUtil.HybridCLRSettings.enable = enable;
                SettingsUtil.HybridCLRSettings.hotUpdateAssemblyDefinitions = hotUpdateAssemblyDefinitions;
                SettingsUtil.HybridCLRSettings.hotUpdateAssemblies = hotUpdateAssemblies;
                SettingsUtil.HybridCLRSettings.patchAOTAssemblies = patchAOTAssemblies;
                HybridCLR.Editor.Settings.HybridCLRSettings.Save();
            }
            else
            {
                Disable();
            }

        }

        [MenuItem("cframework/HybridcCLR/Disable")]
        public static void Disable()
        {
            SettingsUtil.HybridCLRSettings.enable = false;
            SettingsUtil.HybridCLRSettings.hotUpdateAssemblyDefinitions = new AssemblyDefinitionAsset[0];
            SettingsUtil.HybridCLRSettings.hotUpdateAssemblies = new string[0];
            SettingsUtil.HybridCLRSettings.patchAOTAssemblies = new string[0];
            HybridCLR.Editor.Settings.HybridCLRSettings.Save();
        }
    }
}